<!--
 * @Author: 胡俊/treence
 * @Date: 2022-05-11 15:29:12
 * @LastEditors: 黄宇/Hyuishine
 * @LastEditTime: 2024-05-14 15:36:54
 * @Description: 
 * @Email: treence@gmail.com
 * @Company: 3xData
 * @youWant: add you want
-->
<template>
  <view class="containe_messageInfo">
    <action-bar :options="navOptions" />
    <view class="main">
      <view class="title">{{ formObject.noticeTitle }}</view>
      <view class="time">{{ formObject.createTime.substring(0,10) }}</view>
      <view class="content"
            v-html="formObject.noticeContent"></view>
    </view>
  </view>
</template>
<script>
export default {
  props: ['title'],
  data () {
    return {
      navOptions: { // 导航栏配置参数
        statusBar: 'dark',
        left: {
          icon: 'back'
        },
        center: {
          title: '消息'
        }
      },
      formId: '',
      formObject: {
        noticeTitle: '',
        noticeContent: '',
        createTime: ''
      },
      loading: false,
    }
  },
  onLoad (options) {
    this.formId = options.noticeId
  },
  mounted () {
    this.getForm()
  },
  methods: {
    // 获取消息详细
    getForm () {
      return new Promise((resolve, reject) => {
        if (this.loading) reject()

        this.loading = true
        uni.showLoading({
          title: '正在加载请稍后',
          mask: true
        });
        this.$store.dispatch('message_form', this.formId)
          .then(res => {
            if (res && res.code === 200) {
              this.formObject = res.data
              resolve(res.data)
            }
          })
          .finally(() => {
            let timer = setTimeout(() => {
              this.loading = false
              uni.hideLoading();
              clearTimeout(timer)
            }, 3000);
          })
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.containe_messageInfo {
  height: 100vh;
  background-color: #f8f8f8;
  .main {
    margin: 0 34rpx;
    .title {
      margin-top: 20rpx;
      text-align: center;
      color: black;
      font-size: 48rpx;
      font-weight: bold;
    }
    .time {
      text-align: center;
      color: #666;
      font-size: 28rpx;
      line-height: 80rpx;
    }
    .content {
      background-color: white;
      border-radius: 20rpx;
      padding: 30rpx;
      color: #333;
      font-size: 28rpx;
      font-weight: 40rpx;
    }
  }
}
</style>